package com.quick.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.quick.base.Page;
import com.quick.base.Search;
import com.quick.love.pojo.LoveMessage;
import com.quick.love.search.LoveMessageSearch;
import com.quick.love.vo.LoveMessageVo;
import com.quick.mapper.LoveMessageMapper;
import com.quick.service.ILoveMessageService;
import com.quick.util.PageUtil;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoveMessageServiceImpl implements ILoveMessageService {

    private final LoveMessageMapper loveMessageMapper;

    public LoveMessageServiceImpl(LoveMessageMapper loveMessageMapper) {
        this.loveMessageMapper = loveMessageMapper;
    }

    @Override
    public Page<LoveMessageVo> search(Search<LoveMessageSearch> search) {
        PageHelper.startPage(search.getPageNum(), search.getPageSize());
        QueryWrapper<LoveMessage> queryWrapper = new QueryWrapper<>();
        List<LoveMessage> userList = loveMessageMapper.selectList(queryWrapper);
        PageInfo<LoveMessage> pageInfo = new PageInfo<>(userList);
        return PageUtil.page(pageInfo,LoveMessageVo.class);
    }
}
